package com.gcosc.hly.codejava.result;

import lombok.Data;

import java.util.Date;

@Data
public class Result<T> {
    private T data;//响应数据
    private Integer code;//响应码
    private String msg;//响应消息
    private Date time = new Date();//请求时间

    public Result() {
    }

    public Result(Integer code, T data) {
        this.data = data;
        this.code = code;
    }

    public Result(Integer code, T data, String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }

    public static Result ok(){
        return Result.ok(null);
    }

    public static Result ok(Object t){
        return new Result(Code.OK, t,  "成功");
    }

    public static Result msg(String msg){
        return new Result(Code.OK, null,  msg);
    }
}
